# $Id$
# Maintainer: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
# Contributor: Mirco Tischler <mt-ml at gmx dot de>

pkgname=ostree
pkgver=2017.11
pkgrel=1
pkgdesc="Operating system and container binary deployment and upgrades"
url="https://ostree.readthedocs.org/en/latest/"
arch=(i686 x86_64)
license=(GPL)
depends=(glib2 xz zlib libsoup gpgme libarchive fuse2 util-linux mkinitcpio openssl)
makedepends=(e2fsprogs gobject-introspection gtk-doc libxslt systemd git
             python2)
checkdepends=(parallel syslinux gjs cpio elfutils)
_commit=6c0738a000800856d09774d50d16d84c1b537a7b  # tags/v2017.11^0
source=("git+https://github.com/ostreedev/ostree#commit=$_commit"
        "git+https://github.com/mendsley/bsdiff"
        "git+https://git.gnome.org/browse/libglnx")
sha256sums=('SKIP'
            'SKIP'
            'SKIP')

prepare() {
  cd $pkgname

  git submodule init
  git config --local submodule.bsdiff.url "$srcdir/bsdiff"
  git config --local submodule.libglnx.url "$srcdir/libglnx"
  git submodule update

  find . -name '*.py' -exec sed -i '1s/python$/&2/' {} +

  NOCONFIGURE=1 ./autogen.sh
}

pkgver() {
  cd $pkgname
  git describe --tags | sed 's/^v//;s/-/+/g'
}

build() {
  cd $pkgname

  ./configure \
    --prefix=/usr \
    --sysconfdir=/etc \
    --localstatedir=/var \
    --sbindir=/usr/bin \
    --libexecdir=/usr/lib \
    --with-mkinitcpio \
    --with-openssl \
    --with-builtin-grub2-mkconfig \
    --enable-experimental-api \
    --disable-static \
    --enable-gtk-doc

  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool

  make
}

check() {
  cd $pkgname
  make check || :
}

package() {
  cd $pkgname
  make DESTDIR="$pkgdir" install
}
